<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

define('DBC_ROOT', './');
require DBC_ROOT.'engine/common.php';

if ($DBC_user['g_read_board'] == '0')
	exit($lang_common['No view']);

if ($DBC_user['is_guest'])
	exit($lang_common['No permission']);

$action = isset($_POST['action']) ? $_POST['action'] : '';
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
if ($id < 1)
	exit($lang_common['Bad request']);

if ($action == "quote")
{
	// Fetch some info about the post, the topic and the forum
	$result = $db->query('SELECT p.message FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$DBC_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
	if (!$db->num_rows($result))
		exit($lang_common['Bad request']);

	$cur_post = $db->fetch_assoc($result);

	if ($DBC_config['o_censoring'] == '1')
		$cur_post['message'] = censor_words($cur_post['message']);

?>
<quote_post><?php echo $cur_post['message'] ?></quote_post>
<?php

}
else if ($action == "pmquote")
{
	if ($DBC_config['o_pms_enabled'] != '1' || $DBC_user['g_pm'] == 0 || $DBC_user['messages_enable'] == 0)
		exit($lang_common['No permission']);

	// Fetch some info about the post, the topic and the forum
	$result = $db->query('SELECT p.message FROM '.$db->prefix.'pms_new_posts AS p INNER JOIN '.$db->prefix.'pms_new_topics AS t ON t.id=p.topic_id WHERE p.id='.$id.' AND (t.starter_id='.$DBC_user['id'].' OR t.to_id='.$DBC_user['id'].')') or error('Unable to fetch pms_new_posts info', __FILE__, __LINE__, $db->error());
	if (!$db->num_rows($result))
		exit($lang_common['Bad request']);

	$cur_post = $db->fetch_assoc($result);

	if ($DBC_config['o_censoring'] == '1')
		$cur_post['message'] = censor_words($cur_post['message']);

?>
<quote_post><?php echo $cur_post['message'] ?></quote_post>
<?php

}
else
	exit($lang_common['Bad request']);

$db->end_transaction();
$db->close();
